package com.ybb.job.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ybb.job.entity.JobLockEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface JobLockMapper extends BaseMapper<JobLockEntity> {

    @Update("update ybb_job_lock l set l.node_id=#{nodeId}, l.last_update=now() where type=#{type} and ( now()-l.last_update>90 or l.node_id=#{nodeId})")
    Integer getLock(@Param("nodeId") String nodeId, @Param("type") String type);
}
